<template>
	<custom-navigation-bar class="nav-bar" title="订单详情" :back="true">
	</custom-navigation-bar>
	<scroll-view scroll-y style="flex: 1;">
  <view class="container">
   

    <!-- 订单状态卡片 -->
    <view class="order-status-card">
      <view class="order-status {{orderStatus === '已核销' ? 'status-success' : orderStatus === '未核销' ? 'status-pending' : 'status-expired'}}">
        {{orderStatus}}
      </view>
      <view class="order-number">订单编号: {{orderInfo.orderNo}}</view>
    </view>

    <!-- 二维码核销区域 -->
    <view class="qr-code-container">
      <view class="qr-code-wrapper">
        <!-- <image :src="qrCodeUrl" class="qr-code" mode="widthFix" alt="订单核销二维码"></image> -->
		<view class="" style="padding: 6rpx;">
			<ikun-qrcode
				width="250"
				height="250"
				color="#000000"
				:data="qrCodeUrl" 
			/>
			<!-- unit="px" -->
		</view>
        <view class="qr-code-desc">请出示此二维码进行核销</view>
      </view>
    </view>

    <!-- 核销点位区域 -->
    <view class="verification-points">
      <view class="section-title">核销点位</view>
      <view class="points-list">
        <view 
          v-for="(point, index) in verificationPoints" 
          :key="index" 
          class="point-item flex-row"
          :class="{ 'verified': point.verified }"
        >
          <view class="point-info ">
            <view class="point-name">{{point.name}}</view>
            <view class="point-address">{{point.address}}</view>
          </view>
          <view class="point-status">
			  <icon class="icon-small" :type="point.verified ?'success':'circle'" size="23"></icon>
          </view>
        </view>
      </view>
    </view>

    <!-- 订单信息区域 -->
    <view class="order-info-section">
      <view class="section-title">订单信息</view>
      <view class="info-list">
        <view class="info-item flex-row">
          <view class="info-label">使用时间</view>
          <view class="info-value">{{orderInfo.useTime}}</view>
        </view>
        <view class="info-item flex-row">
          <view class="info-label">地点</view>
          <view class="info-value">{{orderInfo.location}}</view>
        </view>
        <view class="info-item flex-row">
          <view class="info-label">联系人</view>
          <view class="info-value">{{orderInfo.contactPerson}}</view>
        </view>
        <view class="info-item flex-row">
          <view class="info-label">联系电话</view>
          <view class="info-value">{{orderInfo.contactPhone}}</view>
        </view>
        <view class="info-item flex-row">
          <view class="info-label">车牌号</view>
          <view class="info-value">{{orderInfo.licensePlate}}</view>
        </view>
        <view class="info-item flex-row">
          <view class="info-label">订单金额</view>
          <view class="info-value price">{{orderInfo.amount}}</view>
        </view>
      </view>
    </view>

    
  </view>
  </scroll-view>
  <!-- 底部操作按钮 -->
  <view class="bottom-actions flex-row justify-between" v-if="orderStatus === '未核销'">
    <button class="action-btn share-btn" @click="shareOrder">
       分享订单
    </button>
    <button class="action-btn cancel-btn" @click="cancelOrder">取消订单</button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 订单状态：已核销、未核销、已过期
      orderStatus: '未核销',
      // 二维码图片地址
      qrCodeUrl: '1',
      // 订单信息
      orderInfo: {
        orderNo: 'ORD2023051200876',
        useTime: '2023-05-15 09:00 - 18:00',
        location: '深圳市南山区科技园',
        contactPerson: '张先生',
        contactPhone: '138****6789',
        licensePlate: '粤B·12345',
        amount: '¥298.00'
      },
      // 核销点位列表
      verificationPoints: [
        {
          name: '科技园A区核销点',
          address: '深圳市南山区科技园南区1栋1楼',
          verified: false
        },
        {
          name: '科技园B区核销点',
          address: '深圳市南山区科技园北区3栋2楼',
          verified: true
        },
        {
          name: '科技园C区核销点',
          address: '深圳市南山区科技园中区5栋1楼',
          verified: false
        }
      ]
    };
  },
  onLoad(options) {
    // 可以通过options接收订单ID等参数，然后请求接口获取订单详情
    // 这里模拟从接口获取数据
    if (options.orderId) {
      // 模拟请求
      setTimeout(() => {
        // 实际项目中这里会根据orderId请求后端接口获取数据
        console.log('加载订单详情:', options.orderId);
      }, 500);
    }
  },
  methods: {
    // 返回上一页
    navigateBack() {
      uni.navigateBack({
        delta: 1
      });
    },
    // 分享订单
    shareOrder() {
      uni.showActionSheet({
        itemList: ['分享给好友', '分享到朋友圈'],
        success: (res) => {
          if (res.tapIndex === 0) {
            // 分享给好友
            uni.showToast({
              title: '已分享给好友',
              icon: 'none'
            });
          } else if (res.tapIndex === 1) {
            // 分享到朋友圈
            uni.showToast({
              title: '已分享到朋友圈',
              icon: 'none'
            });
          }
        }
      });
    },
    // 取消订单
    cancelOrder() {
      uni.showModal({
        title: '取消订单',
        content: '确定要取消此订单吗？',
        success: (res) => {
          if (res.confirm) {
            // 调用取消订单接口
            uni.showToast({
              title: '订单已取消',
              icon: 'none'
            });
            // 更新订单状态
            this.orderStatus = '已取消';
          }
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
/* 基础样式 */
.container {
  min-height: 100vh;
  background-color: #f5f5f5;
  padding-bottom: 80rpx;
}

/* 导航栏样式 */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100rpx;
  background-color: #ffffff;
  padding: 0 30rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-left {
  width: 60rpx;
  height: 100rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navbar-title {
  font-size: 36rpx;
  font-weight: 600;
  color: #333333;
}

.navbar-right {
  width: 60rpx;
  height: 100rpx;
}

/* 订单状态卡片 */
.order-status-card {
  background-color: #ffffff;
  padding: 30rpx;
  margin-bottom: 20rpx;
}

.order-status {
  font-size: 34rpx;
  font-weight: 600;
  margin-bottom: 15rpx;
  padding-left: 10rpx;
  border-left: 6rpx solid;
}

.status-success {
  color: #07c160;
  border-color: #07c160;
}

.status-pending {
  color: #ff9700;
  border-color: #ff9700;
}

.status-expired {
  color: #f53f3f;
  border-color: #f53f3f;
}

.order-number {
  font-size: 28rpx;
  color: #666666;
}

/* 二维码区域 */
.qr-code-container {
  background-color: #ffffff;
  padding: 40rpx 30rpx;
  margin-bottom: 20rpx;
  display: flex;
  justify-content: center;
}

.qr-code-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qr-code {
  width: 280rpx;
  height: 280rpx;
  padding: 15rpx;
  background-color: #ffffff;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  margin-bottom: 20rpx;
}

.qr-code-desc {
  font-size: 28rpx;
  color: #333333;
}

/* 核销点位区域 */
.verification-points {
  background-color: #ffffff;
  padding: 30rpx;
  margin-bottom: 20rpx;
}

.section-title {
  font-size: 32rpx;
  font-weight: 600;
  color: #333333;
  margin-bottom: 25rpx;
  padding-bottom: 15rpx;
  border-bottom: 1rpx solid #eeeeee;
}

.points-list {
  display: flex;
  flex-direction: column;
  gap: 15rpx;
}

.point-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20rpx 0;
  border-bottom: 1rpx solid #f5f5f5;
}

.point-item:last-child {
  border-bottom: none;
}

.point-info {
  flex: 1;
}

.point-name {
  font-size: 30rpx;
  color: #333333;
  margin-bottom: 5rpx;
}

.point-address {
  font-size: 26rpx;
  color: #666666;
}

.point-status {
  width: 60rpx;
  height: 60rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 已核销样式 */
.verified .point-name {
  color: #999999;
  text-decoration: line-through;
}

.verified .point-address {
  color: #999999;
}

/* 订单信息区域 */
.order-info-section {
  background-color: #ffffff;
  padding: 30rpx;
}

.info-list {
  display: flex;
  flex-direction: column;
}

.info-item {
  display: flex;
  justify-content: space-between;
  padding: 20rpx 0;
  border-bottom: 1rpx solid #f5f5f5;
}

.info-item:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 28rpx;
  color: #666666;
}

.info-value {
  font-size: 28rpx;
  color: #333333;
  text-align: right;
}

.price {
  color: #f53f3f;
  font-weight: 600;
}

/* 底部操作按钮 */
.bottom-actions {
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background-color: #ffffff;
  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}

.action-btn {
  flex: 1;
  height: 100rpx;
  line-height: 100rpx;
  text-align: center;
  font-size: 30rpx;
  border-radius: 0;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10rpx;
}

.share-btn {
  background-color: #ffffff;
  color: #333333;
  border-right: 1rpx solid #eeeeee;
}

.cancel-btn {
  background-color: #d63d2d;
  color: #ffffff;
}

/* 图标样式 */
.iconfont {
  font-family: "iconfont" !important;
  font-size: 32rpx;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-arrow-left {
  color: #333333;
}

.icon-check-circle {
  color: #07c160;
}

.icon-circle {
  color: #dddddd;
}

.icon-share {
  font-size: 30rpx;
}
</style>
